package com.auxgroup.hr.front.dao.repository;

import com.auxgroup.hr.front.dao.domain.PsCWfGoutHdr;
import com.auxgroup.hr.front.dao.domain.PsCWfPlaveHdr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lv-PC
 */
@Repository
public interface PsCWfGoutHdrRepository extends
        JpaRepository<PsCWfGoutHdr, String>, JpaSpecificationExecutor<PsCWfGoutHdr> {

    @Modifying
    @Transactional
    @Query(value = "delete from PsCWfGoutHdr where cTransactionNbr=:transNum")
    Integer deleteByTransNum(@Param("transNum") String transNum);

    @Query(value = "SELECT count(*) from ps_c_wf_gout_hdr a where a.c_wf_status = 'a' and a.c_out_class = 'e'  and a.c_ybh = 'n'  and a.c_wf_app_dt >= to_date('20191029','yyyymmdd')", nativeQuery = true)
    List countBenchmarkingNoYbhNumber();

    @Query(value = "SELECT count(*) FROM PS_C_WF_GOUT_HDR A WHERE A.C_WF_STATUS = 'A' and a.c_out_class = 'E'  and a.c_wf_app_dt >= to_date('20191029','YYYYMMDD')", nativeQuery = true)
    List countBenchmarkingNumber();
}